package com.chao.ioc.test;

import java.lang.reflect.Field;

/**
 * @author : Rookie
 * @description :
 * @date : 2023/10/5
 */
public class ReflectUtil {

    public static void setFieldVal(Object obj,String fieldName,Object val) throws NoSuchFieldException, IllegalAccessException {
        Class<?> instanceClass = obj.getClass();
        Field field = instanceClass.getDeclaredField(fieldName);
        field.setAccessible(true);
        field.set(obj,val);
    }
}
